package cn.qingyun.gis.modules.enterprise.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.qingyun.gis.modules.enterprise.entity.CustomerInfo;
import cn.qingyun.gis.modules.enterprise.entity.Hotel;
import cn.qingyun.gis.modules.enterprise.entity.dto.HotelDto;
import cn.qingyun.gis.modules.enterprise.mapper.HotelMapper;
import cn.qingyun.gis.modules.enterprise.service.ICustomerInfoService;
import cn.qingyun.gis.modules.enterprise.service.IHotelService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * <p>
 * 酒店数据 服务实现类
 * </p>
 *
 * @author skb
 * @since 2024-04-14
 */
@Service
public class HotelServiceImpl extends ServiceImpl<HotelMapper, Hotel> implements IHotelService {

    @Autowired
    private ICustomerInfoService customerInfoService;

    /**
     * @description: 获取网格内酒店
     * @author skb
     * @date 2024/4/14 15:25
     */
    @Override
    public List<HotelDto> getHotelList(String code) {
        QueryWrapper<Hotel> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().select(Hotel::getPoiId,Hotel::getPoiName,Hotel::getLon,Hotel::getLat,Hotel::getWkt,Hotel::getIsCooperate).eq(Hotel::getGridCode,code);
        List<Hotel> list = this.list(queryWrapper);
        List<HotelDto> hotelDtos = BeanUtil.copyToList(list, HotelDto.class);
        return hotelDtos;
    }

    /**
     * @description: 获取酒店详情
     * @author skb
     * @date 2024/4/14 15:33
     */
    @Override
    public List<CustomerInfo> getHotelDetails(String id) {
        List<CustomerInfo> list = new ArrayList<>();
        QueryWrapper<CustomerInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(CustomerInfo::getPoiId,id);
        list = customerInfoService.list(queryWrapper);
        return list;
    }
}
